# 配置检查脚本

Write-Host "`n🔍 检查项目优化配置..." -ForegroundColor Cyan

# 1. 检查Redis连接
Write-Host "`n1️⃣ 检查Redis连接..." -ForegroundColor Yellow
try {
    $redisTest = Test-NetConnection -ComputerName "8.152.219.98" -Port 6379 -WarningAction SilentlyContinue
    if ($redisTest.TcpTestSucceeded) {
        Write-Host "  ✅ Redis连接正常" -ForegroundColor Green
    } else {
        Write-Host "  ❌ Redis连接失败" -ForegroundColor Red
    }
} catch {
    Write-Host "  ⚠️  无法测试Redis连接" -ForegroundColor Yellow
}

# 2. 检查RocketMQ连接（可选）
Write-Host "`n2️⃣ 检查RocketMQ..." -ForegroundColor Yellow
try {
    $mqTest = Test-NetConnection -ComputerName "localhost" -Port 9876 -WarningAction SilentlyContinue
    if ($mqTest.TcpTestSucceeded) {
        Write-Host "  ✅ RocketMQ NameServer已启动" -ForegroundColor Green
    } else {
        Write-Host "  ⚠️  RocketMQ未启动（可选，暂不影响）" -ForegroundColor Yellow
    }
} catch {
    Write-Host "  ⚠️  RocketMQ未启动（可选）" -ForegroundColor Yellow
}

# 3. 检查Maven依赖
Write-Host "`n3️⃣ 检查Maven依赖..." -ForegroundColor Yellow
$pomFile = "ruoyi-common\pom.xml"
if (Test-Path $pomFile) {
    $pomContent = Get-Content $pomFile -Raw
    
    if ($pomContent -match "rocketmq-spring-boot-starter") {
        Write-Host "  ✅ RocketMQ依赖已添加" -ForegroundColor Green
    } else {
        Write-Host "  ❌ RocketMQ依赖未添加" -ForegroundColor Red
    }
    
    if ($pomContent -match "commons-pool2") {
        Write-Host "  ✅ Redis连接池依赖已添加" -ForegroundColor Green
    } else {
        Write-Host "  ❌ Redis连接池依赖未添加" -ForegroundColor Red
    }
} else {
    Write-Host "  ❌ 找不到pom.xml文件" -ForegroundColor Red
}

# 4. 检查配置文件
Write-Host "`n4️⃣ 检查配置文件..." -ForegroundColor Yellow
$ymlFile = "ruoyi-admin\src\main\resources\application.yml"
if (Test-Path $ymlFile) {
    $ymlContent = Get-Content $ymlFile -Raw
    
    if ($ymlContent -match "rocketmq:") {
        Write-Host "  ✅ RocketMQ配置已添加" -ForegroundColor Green
    } else {
        Write-Host "  ❌ RocketMQ配置未添加" -ForegroundColor Red
    }
    
    if ($ymlContent -match "optimization:") {
        Write-Host "  ✅ 优化配置已添加" -ForegroundColor Green
    } else {
        Write-Host "  ❌ 优化配置未添加" -ForegroundColor Red
    }
} else {
    Write-Host "  ❌ 找不到application.yml文件" -ForegroundColor Red
}

# 5. 检查配置类
Write-Host "`n5️⃣ 检查配置类..." -ForegroundColor Yellow
$configFile = "ruoyi-common\src\main\java\com\ruoyi\common\config\OptimizationConfig.java"
if (Test-Path $configFile) {
    Write-Host "  ✅ OptimizationConfig配置类已创建" -ForegroundColor Green
} else {
    Write-Host "  ❌ OptimizationConfig配置类未创建" -ForegroundColor Red
}

# 总结
Write-Host "`n━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━" -ForegroundColor Gray
Write-Host "`n📊 配置检查完成！" -ForegroundColor Cyan
Write-Host "`n🎯 下一步：" -ForegroundColor Yellow
Write-Host "  1. 在IDEA中刷新Maven项目（右键项目 → Maven → Reload Project）" -ForegroundColor White
Write-Host "  2. 等待依赖下载完成" -ForegroundColor White
Write-Host "  3. 依赖下载完成后，告诉我继续" -ForegroundColor White
Write-Host "`n💡 提示：如果RocketMQ未启动，不影响项目启动，可以先实现Redis功能" -ForegroundColor Yellow
Write-Host ""

